﻿<!DOCTYPE html>
<html lang="en">
<#include "../include/resource-head.ftl"/>
<#assign active='goodsList'/>
<body>
<#include "../include/common-top.ftl"/>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
    <#include "../include/common-menu.ftl"/>
        <div class="main-content">
            <div class="page-content">
                <div class="col-xs-12">
                    <div class="row-fluid">
                        <div class="widget-box">
                            <div class="widget-header widget-header-blue widget-header-flat">
                                <h4 class="lighter">
                                    <i class="icon-plus"></i>修改礼品
                                </h4>
                            </div>
                            <div class="widget-body">
                                <div class="widget-main">
                                    <div class="step-content row-fluid position-relative">
                                        <form class="form-horizontal" action="/admin/goods/updateGoods" method="post"
                                              enctype="multipart/form-data" onsubmit="return form_submit()">
                                            <input type="hidden" name="id" value="${goods.id!}"/>
                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">礼品名称</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="text" class="width-100" name="name"
                                                           value="${goods.name!}"/>
                                                </div>
                                            </div>
                                            <div class="form-group has-info">
                                                <label
                                                        class="col-xs-12 col-sm-3 control-label no-padding-right">礼品价钱</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="text" class="width-100 double" name="price"
                                                           value="${goods.price?string('#0.00')}"/>
                                                </div>
                                            </div>
                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">状态</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select class="width-95 " name="status">
                                                        <option value="0"
                                                                <#if goods.status??&&goods.status==0>selected="selected"</#if>>
                                                            上架
                                                        </option>
                                                        <option value="1"
                                                                <#if goods.status??&&goods.status==1>selected="selected"</#if>>
                                                            下架
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">类型</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select class="width-95 " name="type">
                                                        <option value="0"
                                                                <#if goods.type??&&goods.type==0>selected="selected"</#if>>
                                                            普通
                                                        </option>
                                                        <option value="1"
                                                                <#if goods.type??&&goods.type==1>selected="selected"</#if>>
                                                            可定制
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">一级分类</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select class="width-95" name="firstcategory" id="firstcategory">
                                                        <option value="男装" data-value="0"
                                                                <#if goods.firstcategory == '男装'>selected</#if>>男装
                                                        </option>
                                                        <option value="女装" data-value="1"
                                                                <#if goods.firstcategory == '女装</'>selected</#if>>女装
                                                        </option>
                                                        <option value="居家" data-value="2"
                                                                <#if goods.firstcategory == '居家'>selected</#if>>居家
                                                        </option>
                                                        <option value="DIY" data-value="3"
                                                                <#if goods.firstcategory == 'DIY'>selected</#if>>DIY
                                                        </option>
                                                        <option value="数码周边" data-value="4"
                                                                <#if goods.firstcategory == '数码周边'>selected</#if>>数码周边
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">二级分类</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select class="width-95" name="secondcategory"
                                                            id="secondcategory">
                                                        <option value="${goods.secondcategory!}">${goods.secondcategory!}</option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">展示图</label>
                                                <div class="col-xs-12 col-sm-6">
                                                    <#if goodsImgList??>
                                                        <#list goodsImgList as item>
                                                            <div class="col-sm-3">
                                                                <img src="/data/${item.path!}" width="120px" height="120px">
                                                                <a class="btn btn-primary btn-sm" onclick="removeImg('${item.id}')">移除</a>
                                                            </div>
                                                        </#list>
                                                    </#if>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">添加展示图</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="file" id="icon" class="width-100" name="icons" multiple/>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">定制展示图</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="file" id="img" class="width-100" name="img"/>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label
                                                        class="col-xs-12 col-sm-3 control-label no-padding-right">描述</label>
                                                <div class="col-xs-12 col-sm-5">
														<textarea class="autosize-transition form-control"
                                                                  name="descript">${goods.descript!}</textarea>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">定制介绍</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <textarea class="autosize-transition form-control" name="introduction">${goods.introduction!}</textarea>
                                                </div>
                                            </div>

                                            <div class="form-group has-info">
                                                <div class="col-xs-1"></div>
                                                <div class="col-xs-12 col-sm-10">
                                                    <textarea id="editor" name="content"
                                                              style="width: 100%;">${goods.content}</textarea>
                                                </div>
                                            </div>
                                            <hr/>
                                            <div class="row-fluid wizard-actions">
                                                <button class="btn" type="reset">重置</button>
                                                <button class="btn btn-success" type="submit">提交</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.page-content -->
        </div>
        <!-- /.main-content -->
    </div>
    <!-- /.main-container -->
</body>
<#include "../include/resource-script.ftl"/>
<script type="text/javascript">
    uploadMostFile("icon");
    uploadFile("img",<#if goods.filePath??>"/data/${goods.filePath!}"<#else>null</#if>);

    function form_submit() {
        var title = $("input[name='name']").val();
        if (title.length == 0) {
            tipMsg("请输入礼品名称");
            return false;
        }
        return true;
    }

    $("#firstcategory").change(function () {
        var first = $("#firstcategory option:selected").data("value");
        $.getJSON("/data/json/category.json",function(result){
            var html = result[first];
            $("#secondcategory").html(html);
        })
    })

    function removeImg(id){
        $.getJSON("/admin/goods/removeImg?id="+id,function(result){
            if(result.code == 200){
                tipMsg("移除成功");
                location.reload();
            }else{
                tipMsg(result.message);
            }
        })
    }

</script>
</html>

